<?php
// +----------------------------------------------------------------------
// | XPFRAMEWORK  [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 https://gitee.com/sdnode All rights reserved.
// +----------------------------------------------------------------------
// | Author: chenshiming
// +----------------------------------------------------------------------

namespace app\api\controller\csmwj;

use addons\csmwj\library\xcore\xcore\base\XcAApi;
use addons\csmwj\library\xcore\xcore\utils\XcRequestUtils;

/**
 * DMO
 *
 * @icon fa fa-circle-o
 */
class XpAdminFormGeneratorApi extends XcAApi
{

    public function xinit(){}

    public function getPaperQuestions()
    {
        check_cors_request();

        $id = XcRequestUtils::get('id', true);

        $questionlist = null;
        if (true) {
            $dao = new \app\admin\model\csmwj\Question();
            $questionlist = $dao->where('csmwj_paper_id', '=', $id)
                ->where('status', '=', 'normal')
                ->order('weigh', 'desc')
                ->select();
        }

        $fields = [];
        foreach ($questionlist as $item) {
            $fields[] = empty($item->field) ? [] : json_decode($item->field, true);
        }

        $this->success(null, [
            'fields' => $fields
        ]);
    }
}
